/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.pacs.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.Map;

/**
 *
 * @author 52461
 */
public class RecviceCtrl extends Controller {

    public void index() {

        render("/view/recviceList.jsp");

    }
    
    public void getRecviceList(){
    
         Map<String,String> info = (Map<String,String>) getSession().getAttribute("CX_JSESSION_USER");
         String user = " ";
        String sql = "select * ";
        String status = getPara("status");
      
        System.out.println(status+"--------");
        if(getSessionAttr("remote_user")==null||!getSessionAttr("remote_user").toString().equalsIgnoreCase("true")){
            user += " where (recvicer_id='"+info.get("username")+"' or recvicer_id='"+info.get("uuid")+"') and ";
        }
          String param = "from  asklist  "+user.replace("and", "")+" order by createtime desc";
        if (status != null&!status.equalsIgnoreCase("")) {
            param = "from  asklist where "+user.replace("where", "")+" status='"+status+"' order by createtime desc";

        }
        System.out.println(sql + param);
        Page<Record> userPage = Db.paginate(getParaToInt("currentPage"), getParaToInt("pageSize", 10), sql, param); 

        renderJson(userPage); 
        
    }
    
      //更新报告状态
    public void changeStatus(){
        if(Db.findFirst("select * from asklist where pk='"+getPara("order_id")+"' and status=2")==null){
         Db.update("update asklist set status=1 where pk=" + getPara("order_id"));
        }
        renderText("true");
    }
     public void viewApply() {

//        setAttr("ask_code", getPara("ask_code"));
//        render("/view/ask/apply.jsp");
       redirect("/main/view/ask/viewApply", true);
    }
}
